#ifndef BIMOSSENSOR_H
#define BIMOSSENSOR_H

#include <QObject>
#include <QString>
#include <QDataStream>
#include <cmath>
#include <QDebug>

#define NORM_TEMPERATURE  273
#define NORM_PRESSURE  1013


class BimosSensor : public QObject
{

    Q_OBJECT

public:

    BimosSensor(int ordinal);

    int getOrdinal();
    double getVolt();
    double getMeanVolt();

    // name of sensor
    QString name;

    // access private field for serialization
    friend QDataStream& operator<<(QDataStream &outStream, const BimosSensor &data);
    friend QDataStream& operator>>(QDataStream &inStream, BimosSensor &data);

protected:

    quint8 ordinal;
    qreal volt;

    static const int mean_size = 100;
    double mean_cnt;
    double mean;

private:
    void calculateMean();

public slots:
    void setVolt(double newValue);

signals:
    void valueChanged(BimosSensor*);


friend class QDataStream;
};


#endif // BIMOSSENSOR_H
